<template>
  <div class="main">
    <van-nav-bar title="医院列表" left-text="返回" left-arrow   @click-left="onClickLeft">
    </van-nav-bar>
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
    <van-list
      v-model="loading"
      :error.sync="error"
      error-text="请求失败，点击重新加载"
      @load="onLoad"
    >
      <van-swipe-cell>
        <template #left>
          <van-button square type="primary" text="选择" />
        </template>
        <van-cell>
          <van-row >
            <van-col span="8" class="text-overstriking">医院名称:xxx</van-col>
            <van-col span="8" class="text-overstriking">医院类型:xxx</van-col>
            <van-col span="8" class="text-overstriking">医院地址:xxx</van-col>
          </van-row>
        </van-cell>
        <template #right>
          <van-button square type="danger" text="修改" />
          <van-button square type="primary" text="详情" />
        </template>
      </van-swipe-cell>

    </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
export default {
  name: 'Topic',
  components: {},
  props: [],
  data () {
    return {
      list: [],
      error: false,
      loading: false,
      finished: false,
      refreshing: false
    }
  },
  computed: {},
  created () {},
  mounted () {},
  watch: {},
  methods: {
    onLoad () {
      setTimeout(() => {
        if (this.refreshing) {
          this.list = []
          this.refreshing = false
        }

        for (let i = 0; i < 10; i++) {
          this.list.push(this.list.length + 1)
        }
        this.loading = false

        if (this.list.length >= 40) {
          this.finished = true
        }
      }, 1000)
    },
    onRefresh () {
      // 清空列表数据
      this.finished = false

      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true
      this.onLoad()
    },
    onClickLeft () {
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped lang='less'>

</style>
